multikey.js ➔ multikey   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 4
crap 4
1
export default function multikey(original, key) {
2 2
    return original.map((value) => {
3 8
        const item = {};
4
5 8
        if (typeof key === 'object') {
6 4
            key.forEach((itemKey) => {
7 8
                item[itemKey] = value[itemKey];
8
            });
9
10 4
            return item;
11
        }
12
13 4
        return value[key];
14
    });
15
}
16